# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=u-msgpack
pkgbase=mingw-w64-python-${_realname}
_pkgname=${_realname}-python
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.6.0
pkgrel=1
pkgdesc="portable, lightweight MessagePack serializer and deserializer for Python (mingw-w64)"
arch=('any')
url='https://github.com/vsergeev/${_pkgname}'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/vsergeev/u-msgpack-python/archive/v${pkgver}.tar.gz")
sha256sums=('2b1a6af7992a89f16ba9000ad1483d7921086d2ebe473f5a04576cbc5e9ba70d')

prepare() {
  cd ${srcdir}
  rm -rf python-build-${CARCH} | true
  cp -r "${_pkgname}-${pkgver}" "python-build-${CARCH}"

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py check
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
